import { Config } from "../../Config"
import { Player } from "../core/Player"
import { Point, Terrain } from "../core/Point"
import Utils from "../GameUtils"
import { BaseHandler } from "./BaseHandler"

export class 炮台Handler extends BaseHandler{

    /** 开炮，一段时间后再计算落点上的大子会不会死，有可能空炮 */
    炮台_impact(data:any,player:Player) {
        this.handlerMgr.spendAction(player,Config.COST_炮台_IMPACT)
        let startPoint = this.gameMgr.map_point.get(data.start)
        let big_start = startPoint.big
        big_start.actionOnce()
        let endPoint = this.gameMgr.map_point.get(data.end)
        this.shellLanding(player,startPoint,endPoint)
    }

    /** 炮弹落地 */
    shellLanding(player:Player, startPoint:Point, endPoint:Point) {
        this.gameMgr.sendBroadcast(Utils.getObj("大炮_bombing",{"start":startPoint.id,"end":endPoint.id}))
        setTimeout(()=>{
            let big_end = endPoint.big
            if(big_end != null) {
                big_end.attacked(player)
            }
        },600)
    }

}